package collection;

import java.util.Arrays;
import java.util.List;

//数组转换成集合
public class ArrayToList {
    public static void main(String[] args) {
        String []array={"one","two","three","four","five"};
        System.out.println("array"+array);
        //asList()方法会返回内部的ArrayList，内部直接引用给定数组array
        List<String>list= Arrays.asList(array);
        System.out.println("list"+list);
        array[1]="six";
        System.out.println("array"+Arrays.asList(array));
        System.out.println("list"+list);
        list.set(2,"seven");
        System.out.println("array"+Arrays.asList(array));
        System.out.println("list"+list);
        //给集合添加/删除元素相当于给数组/删除元素
        //而数组是定长的，不会自动扩容/缩容


    }
}
